import React from 'react'
import LoginPage from '@/pages/login';
import { WaterMark } from '@ant-design/pro-layout';
import { ConfigProvider } from 'antd';

const Root = ({ isLogin,children,setting }:any) => {
  let page = <></>;
  if (!isLogin) {
    // 没有登录返回登录页面
    page = <LoginPage />;
  } else if (setting.waterMarkProps != null && setting.waterMarkProps.content != null) {
    // 返回水印的页面
    page =
      <WaterMark {...setting.waterMarkProps}>
        <div style={{ height: 'calc(100vh - 48px)', minHeight: '300px' }}>{children}</div>
      </WaterMark>;
  } else {
    // 返回没有水印的页面
    page = <div style={{ height: 'calc(100vh - 48px)', minHeight: '300px' }}>{children}</div>;
  }
  if (!setting.hasOwnProperty('config')) {
    setting.config = {
      componentSize: 'large'
    }
  }
  return (
    <ConfigProvider {...setting.config}> {page} </ConfigProvider>
  )
}
export default Root;
